home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1998 January / PC Answers Issue 49 Cover CD January 1998.iso / Apps / Director / DATA.Z / Stream-GeoFacts.dir / Scripts_22_Net Activate When Ready Behavior.ls < prev    next >
Encoding:
Text File  |  1997-05-10  |  4.0 KB  |  153 lines

  1. property normalColor, hiColor, downColor, linkLabel, rolloverColor, active, segmentEnd
  2.  
  3. on beginSprite me
  4.   set the visible of sprite the spriteNum of me to 0
  5.   set normalColor to the foreColor of sprite the spriteNum of me
  6.   if downColor = EMPTY then
  7.     set downColor to -1
  8.   else
  9.     set downColor to integer(downColor)
  10.   end if
  11.   if hiColor = EMPTY then
  12.     set hiColor to downColor
  13.   else
  14.     set hiColor to integer(hiColor)
  15.   end if
  16.   if rolloverColor = EMPTY then
  17.     set rolloverColor to -1
  18.   else
  19.     set rolloverColor to integer(rolloverColor)
  20.   end if
  21.   if stringp(linkLabel) then
  22.     if linkLabel contains "marker(" then
  23.       do("set linkLabel=" & linkLabel)
  24.       set segmentEnd to 0
  25.     else
  26.       set segmentEnd to label(linkLabel & "-end")
  27.       set linkLabel to label(linkLabel)
  28.     end if
  29.     set linkLabel to string(linkLabel)
  30.   else
  31.     set segmentEnd to 0
  32.   end if
  33.   fixState(me)
  34. end
  35.  
  36. on fixState me
  37.   if atMyLocation(me) = 1 then
  38.     set the foreColor of sprite the spriteNum of me to hiColor
  39.   else
  40.     if ready(me) then
  41.       activate(me)
  42.     else
  43.       deactivate(me)
  44.     end if
  45.   end if
  46. end
  47.  
  48. on atMyLocation me
  49.   if stringp(linkLabel) then
  50.     if the frameLabel contains "-end" then
  51.       set checkMarker to -1
  52.     else
  53.       set checkMarker to 0
  54.     end if
  55.     if (the frame = integer(linkLabel)) or (marker(checkMarker) = integer(linkLabel)) then
  56.       return 1
  57.     end if
  58.   else
  59.     return 0
  60.   end if
  61. end
  62.  
  63. on ready me
  64.   if stringp(linkLabel) then
  65.     if segmentEnd then
  66.       return frameReady(segmentEnd)
  67.     else
  68.       return frameReady(integer(linkLabel))
  69.     end if
  70.   else
  71.     if integerp(linkLabel) then
  72.       return frameReady(marker(linkLabel))
  73.     end if
  74.   end if
  75. end
  76.  
  77. on activate me
  78.   set the foreColor of sprite the spriteNum of me to normalColor
  79.   set the visible of sprite the spriteNum of me to 1
  80.   set active to 1
  81. end
  82.  
  83. on deactivate me
  84.   set the visible of sprite the spriteNum of me to 0
  85.   set active to 0
  86. end
  87.  
  88. on mouseDown me
  89.   if (downColor >= 0) and active then
  90.     set the foreColor of sprite the spriteNum of me to downColor
  91.     updateStage()
  92.   else
  93.     if not active then
  94.       nothing()
  95.     end if
  96.   end if
  97. end
  98.  
  99. on mouseUp me
  100.   if active then
  101.     if stringp(linkLabel) then
  102.       puppetTransition(4, 1)
  103.       go(integer(linkLabel))
  104.     else
  105.       if integerp(linkLabel) then
  106.         puppetTransition(4, 30)
  107.         go(marker(linkLabel))
  108.       end if
  109.     end if
  110.     sendAllSprites(#fixState)
  111.   end if
  112. end
  113.  
  114. on mouseEnter me
  115.   if active and not atMyLocation(me) then
  116.     set the foreColor of sprite the spriteNum of me to rolloverColor
  117.     updateStage()
  118.   end if
  119. end
  120.  
  121. on mouseLeave me
  122.   if active and not atMyLocation(me) then
  123.     if atMyLocation(me) then
  124.       set the foreColor of sprite the spriteNum of me to hiColor
  125.     else
  126.       set the foreColor of sprite the spriteNum of me to normalColor
  127.     end if
  128.     updateStage()
  129.   end if
  130. end
  131.  
  132. on exitFrame me
  133.   if not active then
  134.     if ready(me) then
  135.       activate(me)
  136.     end if
  137.   end if
  138. end
  139.  
  140. on endSprite me
  141.   set the visible of sprite the spriteNum of me to 1
  142.   puppetSprite(the spriteNum of me, 0)
  143. end
  144.  
  145. on getPropertyDescriptionList
  146.   set p_list to [#downColor: [#comment: "Mouse Down Color:", #format: #integer, #default: EMPTY], #hiColor: [#comment: "Hilited Color:", #format: #integer, #default: EMPTY], #rolloverColor: [#comment: "rollOver Color:", #format: #integer, #default: EMPTY], #linkLabel: [#comment: "Marker To Go To:", #format: #string, #default: EMPTY]]
  147.   return p_list
  148. end
  149.  
  150. on getBehaviorDescription
  151.   return "Use a shape cast member as a button to link to other markers in the current movie." & "The default color is picked up from the color in the score at initialization." & RETURN & "PARAMETERS:" & RETURN & "ΓÇó Mouse Down Color  - The shape will use this color when clicked." & RETURN & "ΓÇó Hilited Color (optional) - The shape will use this color when the movie is in the label that the shape links to." & RETURN & "ΓÇó rollOver Color - The rollOver state color for the shape or bitmap." & RETURN & "ΓÇó Marker To Go To  - The shape go to this label when clicked."
  152. end
  153.